#pragma once

#include "SDLComponent.h"
#include "SDLResources.h"
#include "SDLRenderer.h"
#include "Point.h"

class SDLSprite :
	public SDLComponent
{
public:
	SDLSprite(std::string _fileName);
	SDLSprite(int _frameX, int _frameY, int _width, int _height, std::string _fileName);
	SDLSprite(int _posX, int _posY, int _frameX, int _frameY, int _width, int _height, std::string _fileName);
	SDLSprite(int _posX, int _posY, int _frameX, int _frameY, int _width, int _height, std::string _fileName, SDLScene* _scene);
	SDLSprite(SDL_Surface* _surface);
	SDLSprite(SDL_Surface* _surface, SDLScene* _scene);
	SDLSprite(const SDLSprite& _source);
	SDLSprite(int _posX, int _posY, SDL_Surface* _surface);
	virtual ~SDLSprite();

	int GetX() const { return m_PosX; }
	int GetY() const { return m_PosY; }
	bool IsVisible() const { return m_Visible; }

	void SetPosition( int _x, int _y )
	{
		m_PosX = _x;
		m_PosY = _y;
	}
	void SetPosition( const Point& p )
	{
		m_PosX = p.GetX();
		m_PosY = p.GetY();
	}
	void SetVisible(bool _visible)
	{
		m_Visible = _visible; 
	}
	void SetFrame(int _posX, int _posY, int _width, int _height);
	void SetFrame(int _posX, int _posY, int _frameX, int _frameY, int _width, int _height);

protected:
	virtual void Start(){}
	virtual void Update(){}
	virtual void Stop(){}

	int m_PosX;
	int m_PosY;
	int m_FrameX;
	int m_FrameY;
	int m_Width;
	int m_Height;

	bool m_Visible;

	SDL_Surface* m_Source;

private:
	void Draw();
	//void ApplySurface(int x, int y, SDL_Surface* src, SDL_Surface* dest);
	void ApplySurface(int x, int y, SDL_Rect* const srcRect, SDL_Surface* src, SDL_Surface* dest);

};

